﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using static sx_windows.data.repository.source.Request;

namespace sx_windows.utils
{
    public static class CMD
    {
        public static string execute(string cmd)
        {
            System.Diagnostics.Process _pCmd;
            _pCmd = new System.Diagnostics.Process();
            _pCmd.StartInfo.FileName = "cmd.exe";
            _pCmd.StartInfo.UseShellExecute = false;
            _pCmd.StartInfo.RedirectStandardOutput = true;
            _pCmd.StartInfo.RedirectStandardInput = true;
            _pCmd.StartInfo.CreateNoWindow = true;
            _pCmd.Start();
            _pCmd.StandardInput.WriteLine(cmd);
            _pCmd.StandardInput.WriteLine("exit");
            _pCmd.WaitForExit();
            string result = _pCmd.StandardOutput.ReadToEnd();
            _pCmd.Close();
            return result;
        }
    }
}
